package com.charm.nukaties.framework.nethard


import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory

/**
 *
 * @author tools
 * @date 2017/12/11
 */

class RetrofitFactory {
    companion object {
        var retrofit: Retrofit? = null
        @Synchronized
        fun build(baseUrl: String): Retrofit {
            if (retrofit != null) {
                return retrofit!!
            }
            retrofit = Retrofit.Builder()
                    .client(OkHttpFactory.create())
                    .addConverterFactory(GsonConverterFactory.create())
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .baseUrl(baseUrl)
                    .build()
            return retrofit!!
        }
    }
}
